#ifndef BUS_H
#define BUS_H

// System includes
#include <QList>

/**
*   Bus
*   Does book keeping for acquiring unique buses and a sorted list of buses in use
*/
class Bus
{
public:

    /**
    *   Bus constructor
    *   @param int contiguousBuses
    */
    Bus(int contiguousBuses);

    /**
    *   acquireAudioBus requests a unique bus number, taking into account the contiguous buses variable
    *   @return int the number of the bus that was reserved
    */
    int acquireAudioBus();

    /**
    *   releaseAudioBus
    *   @param int The number of the bus (plus the contiguous buses var) to remove
    */
    void releaseAudioBus(int bus);

    /**
    *   acquireControlBus requests a unique bus number, taking into account the contiguous buses variable
    *   @return int the number of the bus that was reserved
    */
    int acquireCoontrolBus();

    /**
    *   releaseCurrentBus
    *   @param int The number of the bus (plus the contiguous buses var) to remove
    */
    void releaseControlBus(int bus = 3);

    static const int FIRST_BUS = 30;

private:

    /** the number of buses to reserved between entries */
    int mContiguousBuses;
    /** current sorted list of audio buses */
    QList<int> audioBusList;
    /** current sorted list of control buses */
    QList<int> controlBusList;
};

#endif // BUS_H
